#ifndef __6502_HH
#define __6502_HH

#include <vector>
#include <iostream>
#include <fstream>
#include <string>

namespace CPU
{
    const int RAM_SIZE = 65536;
    
    enum flags
    {
        N = 7,
        V = 6,
        B = 4,
        D = 3,
        I = 2,
        Z = 1,
        C = 0,
    };
    
    class CPU
    {
    public:
        CPU();
        virtual ~CPU();

        void reset();
        void run();
        void step();

        unsigned char ram(const unsigned short offset) const;

    protected:
        inline bool flag(const flags f) const;
	inline unsigned short address_at(const unsigned short address) const;
        
    private:
        unsigned char  a_;
        unsigned char  x_;
        unsigned char  y_;
        unsigned char  p_;
        unsigned short pc_;

	std::vector<unsigned char> ram_;

	void load_ram(std::string filename);
    };
}

#endif
